;
define(["MComponent","MLLayer"], function(MComponent,MLLayer) {
	/**
	 * 主框架
	 * @param {Object} background 背景
	 */
	var MFrame = function(background) {
		this.bodydom = this.query("body","MFrame");
		this.htmldom = this.query("html");
		
		var layer = new MLLayer();
		this.dom = this.bodydom;
		
		/**
		 * 设置为定位后的大小
		 */
		this.setPositionSize = function(){
			if(this.getPositionModel() == 'static') {
				throw "该组件不支持定位，原因是组件定位模式为static。";
			}
			this.dom = this.htmldom;
			this.setFullToParent();
			this.dom = this.bodydom;
			this.setFullToParent();
			return this;
		};
		
		this.setBackground = function(value){
			if(value instanceof MComponent){
				value.setSize(this.getWidth(),this.getHeight());
				layer.get(0).setContent(value);
			}else{
				layer.get(0).setBackground(value);
			}
			return this;
		}
		
		this.getContent = function(pa){
			return layer.get(1);
		}
		
		this.setLayerVisible = function(flag){
			return layer.setVisible(flag);
		}
		
		this.getGlassPanel = function(){
			return layer.get(2);
		};
		
		this.setGlassPanelVisible = function(flag){
			layer.get(2).setVisible(flag)
			return this;
		};
		
		this.init();
		this.init = function(){
			layer.put(0);
			layer.put(1);
			layer.put(2);
			layer.put(3);
			layer.get(2).setVisible(false);
			layer.get(3).setVisible(false);
			this.append(layer);
			this.setLayerVisible(false);
		}
		this.init();
		this.setBackground(background);
	};
	mofum.extend(MFrame, MComponent);
	return MFrame;
});